package com.ai.nsa.utils.hbase.model;

import com.ai.nsa.utils.LeftPad;

import static com.ai.nsa.NSAConstants.*;

/**
 * @author Feng Chen 2017/6/8.
 */
public class RowKey {

    private String part;

    private String id;

    private String date;

    private String serial;

    public RowKey() {

    }

    public RowKey part(String part) {
        this.part = part;
        return this;
    }

    public RowKey id(String id) {
        this.id = id;
        return this;
    }

    public RowKey date(String date) {
        this.date = date;
        return this;
    }

    public RowKey serial(String serial) {
        this.serial = serial;
        return this;
    }

    public String get() {
        StringBuilder builder = new StringBuilder();
        builder.append(LeftPad.pad(part, PARTITION_LENGTH, ROWKEY_PAD));
        builder.append(id);
        builder.append(date);
        builder.append(LeftPad.pad(serial, SERIAL_LENGTH, ROWKEY_PAD));
        return builder.toString();
    }

    public String getPart() {
        return part;
    }

    public String getId() {
        return id;
    }

    public String getDate() {
        return date;
    }

    public String getSerial() {
        return serial;
    }

}
